Chris Pollett >
Old Classes
> |
HW#1 --- last modified March 02 2019 17:19:23..Due date: Feb 18
Files to be submitted: Purpose: To quickly get familiar with Scheme. To experiment with best first search algorithms. Specification: The suggested study problems for this assignment are: 3.8, 3.13, 4.1, 4.7. You do not need to turn these in. For this assignment you will write a function which determines a path from the start position to the end position of a maze. We define a maze in two steps. First, a floorplan is a square array of 0's and 1's. A 0 indicates an unoccupied square. That is, a square a player can walk in. A 1 indicates a sqaure a player cannot occupy (can think of as a wall). A path from square s in a floorplan to square t is a sequence of left, right, up, down moves from square s such that at each step in the sequence the move is onto an unoccupied square in the floorplan. A floorplan is a maze if the top left square is unoccupied (this is the start position) and the bottom right square is unoccupied (this is the end position) and there is a path between these two squares. A maze-game is a Scheme object that supports the following messages: 'init! -- initialize the maze with the player in the start square. 'copy -- returns another object which is a copy of the current board. 'up! -- move the player up one square. If succeed return true else false. 'down! -- move the player down one square. If succeed return true else false 'left! -- move the player left one square. If succeed return true else false. 'right! -- move the player right one square. If succeed return true else false. 'size -- returns the size of the dimension of the maze. (i.e., n if it is an n x n-maze). 'distance-up -- returns the number of unoccupied square in the upward direction from the current location until one hits the edge of the maze or an occupied square. The next three messages are similar but for the corresponding direction: 'distance-down 'distance-right 'distance-left 'goal? -- returns #t if player is at the end of maze. For this assignment your job is to write a program find-path-maze-game which on input a maze-game outputs a list containing a sequence of 'up!, 'down!, 'left!, 'right! messages which when applied in order yield a path from the start position to the end position in the maze-game. The goal further is to get your program to do this better than anybody else's in the class. As an example of how your program may be tested. Suppose the constructor make-random-maze-game creates a maze of the supplied size. So to create a maze at the Scheme prompt one could do:
As one more example of a possible maze-game, here is an example implementation of a constructor that can be used to create a blank maze of size n:
To use the above could have a line like:
This is a link to some code discussed in class for creating large boards and for doing greedy search. Point Breakdown
|